package dao.impl;

import bean.User;
import dao.UserDao;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import util.C3p0Util;

import java.sql.SQLException;

/**
 * 系统用户数据交互实现类
 */
public class UserDaoImpl implements UserDao {

    @Override
    public User findUserByInfo(String userName, String password, int role) throws SQLException {

        String sql = "select * from t_user where userName = ?and password = ? and role = ?";
        QueryRunner qr = new QueryRunner(C3p0Util.getDs());
        User user = qr.query(sql,new BeanHandler<User>(User.class),userName,password,role);
        return user;
    }
}